package com.biz.primus.model.coupon.vo.coupon.request;

import com.biz.primus.base.exception.utils.AssertUtils;
import com.biz.primus.model.coupon.enums.CouponAcquireApproach;
import com.biz.primus.model.coupon.exceptions.CouponExceptionType;
import com.biz.primus.model.coupon.exceptions.CouponTypeExceptionType;
import com.biz.primus.model.coupon.interfaces.IModelValidation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.collections4.CollectionUtils;

/**
 * 创建优惠券请求Vo
 *
 * @author david-liu
 */
@ApiModel
@Getter
@Setter
public class CreateCouponReqVo implements Serializable, IModelValidation {

    private static final long serialVersionUID = -4288956917806561368L;

    @ApiModelProperty(value = "优惠券类型ID")
    private Long couponTypeId;

    @ApiModelProperty(value = "用户ID集合")
    private List<Long> userIds;

    @ApiModelProperty(value = "优惠券数量")
    private Integer quantity;

    @ApiModelProperty(value = "优惠券领取方式")
    private CouponAcquireApproach couponAcquireApproach;

    @Override
    public void validate() {
        AssertUtils.notNull(couponTypeId, CouponTypeExceptionType.PARAMETER_ILLEGAL, new Object[]{"优惠券类型ID不能为空"});
        AssertUtils.isTrue(CollectionUtils.isNotEmpty(userIds), CouponExceptionType.CREATE_COUPON_USER_NOT_EXIST);
        AssertUtils.notNull(quantity, CouponExceptionType.CREATE_COUPON_QUANTITY_ILLEGAL);
        AssertUtils.notNull(couponAcquireApproach, CouponExceptionType.COUPON_ACQUIRE_APPROACH_NOT_ALLOW_NULL);
    }
}
